package com.pactera.madp.cp.service.impl;

import cn.hutool.core.date.DateUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.pactera.madp.cp.api.entity.crm.WorkDkfinaExpireInfoEntity;
import com.pactera.madp.cp.mapper.WorkDkfinaExpireInfoMapper;
import com.pactera.madp.cp.service.WorkDkfinaExpireInfoService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

@Slf4j
@Service
@AllArgsConstructor
public class WorkDkfinaExpireInfoServiceImpl extends ServiceImpl<WorkDkfinaExpireInfoMapper, WorkDkfinaExpireInfoEntity> implements WorkDkfinaExpireInfoService {

    private final WorkDkfinaExpireInfoMapper workDkfinaExpireInfoMapper;

    @Override
    public boolean sync() {
        return workDkfinaExpireInfoMapper.sync();
    }

    @Override
    public Integer getNewestCount(String wxUserId) {
        return workDkfinaExpireInfoMapper.selectCount(new LambdaQueryWrapper<WorkDkfinaExpireInfoEntity>()
                .eq(WorkDkfinaExpireInfoEntity::getDataDt, DateUtil.format(DateUtil.yesterday(),"yyyyMMdd"))
                .eq(WorkDkfinaExpireInfoEntity::getWarnPerson,wxUserId));
    }

}
